package com.electric.qrapp.webView

import android.content.Context
import androidx.lifecycle.MutableLiveData
import com.electric.qrapp.ui.base.repo.BaseRepository
import com.electric.qrapp.utils.data.DataManager
import com.electric.qrapp.utils.function.getSaveFileDir
import com.electric.qrapp.utils.view.LoadingUtils
import java.io.File
import javax.inject.Inject

/**
 *@author created by WA03675
 *@date  2022-03-21 16:54
 *@des
 */
class WebViewRepository @Inject constructor() : BaseRepository() {
    @Inject
    lateinit var dataManager: DataManager


    /**
     *文件压缩
     * @param context
     * @param fileList
     * @param vmAlbum
     * @param loadingUtils
     */
    fun compressFile(context: Context, fileList: List<String>, vmAlbum: MutableLiveData<String>, loadingUtils: LoadingUtils) {
        val fileFolder = File(
            getSaveFileDir()
        ).apply {
            //删除上一次压缩的文件
            if (this.exists()) {
                this.delete()
            }

            if (!this.exists()) {
                this.mkdirs()
            }
        }

        com.electric.qrapp.utils.function.compressFile(context, fileFolder.absolutePath.toString(), fileList, vmAlbum, loadingUtils)
    }


}